package _jdk_https_rel;

import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.util.Arrays;

/**
 * @Author: huangya
 * @Date: 2019/5/24
 * @Description:
 */
public class ssl_tls_supprt {

    public static void main(String[] args) throws NoSuchProviderException, NoSuchAlgorithmException, KeyManagementException {
        SSLContext s = SSLContext.getInstance("TLS", "SunJSSE");
        // 初始化SSLContext实例
        s.init(null, null, new java.security.SecureRandom());
        // 打印这个SSLContext实例使用的协议
        System.out.println("缺省安全套接字使用的协议: " + s.getProtocol());
        // 获取SSLContext实例相关的SSLEngine
        SSLEngine e = s.createSSLEngine();
        System.out.println("支持的协议: " + Arrays.asList(e.getSupportedProtocols()));
        System.out.println("启用的协议: " + Arrays.asList(e.getEnabledProtocols()));
        System.out.println("支持的加密套件: "  + Arrays.asList(e.getSupportedCipherSuites()));
        System.out.println("启用的加密套件: "  + Arrays.asList(e.getEnabledCipherSuites()));
    }
}
